var Ball = function (g) {
    let img = g.imgByName('ball')
    let o = {
        image: img,
        x: 100,
        y: 150,
        speedX: 8,
        speedY: 8,
        fired: false,
    }
    o.move = function () {
        if (o.fired) {
            if (o.x <= 0 || o.x >= 420) {
                o.speedX *= -1
            }
            if (o.y <= 0 || o.y >= 300) {
                o.speedY *= -1
            }
            // log('move')
            o.x += o.speedX
            o.y += o.speedY
        }
    }
    o.rebound = function (paddle) {
        // dirction {'X': true, 'Y': false}
        var direction = poundDirrection(paddle, o) 
        if (direction.X) {
            o.speedX *= -1
        }
        if (direction.Y) {
            o.speedY *= -1
        }
    }
    o.fire = function () {
        o.fired = true
    }
    o.pause = function () {
        o.fired = false
    }
    return o
}